package cn.azy.activemq.producer.controller;

import cn.azy.activemq.entity.Message;
import cn.azy.activemq.producer.role.QueueProducer;
import cn.azy.activemq.producer.role.TopicProducer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * @ Author     ：AZY.
 * @ Date       ：Created in 17:07 2019/10/16
 * @ Description：${DESCRIPTION}
 */
@RestController
@Slf4j
public class ProviderController {
    @Autowired
    private QueueProducer queueProducer;
    //注入存放消息的队列，用于下列方法一

    @Autowired
    private TopicProducer topicProducer;

    @GetMapping("/value")
    public String value(Message message) {
        String queueName="QUEUE_RECEIVE_ADD_FIREND"; //自定义队列名称
        String topicName="TOPIC_RECEIVE_ADD_FIREND";
        log.info(message.toString());
        queueProducer.sendObjectMessage(queueName, message);   //发送到MQS
//        topicProducer.sendObjectMessage(topicName, msg);
        return "消息已经发送";
    }

}
